<template>
	<view class="">
		<view class="usertop">
			<view class="" :style="'height: '+statusBarHeight+'px;'"></view>

			<!-- #ifndef MP-WEIXIN -->
			<view class="set" @click="jump('/pageA/set')">
				<image src="../../static/newProject/set.png" mode=""></image>
			</view>
			<!-- #endif -->
		</view>
		<!-- <view class="" :style="'height: '+statusBarHeight +'px;'"></view> -->
		<view class="isuser" :style="'margin-top: '+statusBarHeight +'px;'">
			<view class="ediauser">
				<view class="ediauser_left">
					<image :src="$fun.imgUrl(userInfo.avatar)" @click="uploadPic" mode=""></image>
					<view class="naview">
						<view class="">{{userInfo.nickname}}</view>
						<view class="textid">{{userInfo.mobile}}</view>
					</view>
				</view>
				<!-- <image src="../../static/goin.png" mode=""></image> -->
				<!-- #ifdef MP-WEIXIN -->
				<view class="set" @click="jump('/pageA/set')">
					<image src="../../static/newProject/set.png" mode=""></image>
				</view>
				<!-- #endif -->
			</view>
			<view class="usertop_bot">
				<view class="left">
					<image src="../../static/vip@2x.png" mode=""></image>
					<text>{{userInfo.levelname}}</text>
				</view>
				<view class="right" @click="goup(userInfo.levelname)">去升级</view>
			</view>
			<view class="usermain">
				<view class="usermain_nab">
					<view class="" @click="$fun.jump('/pageA/order/order?state=0')">
						<image src="../../static/nav(3).png" mode=""></image>
						<view class="">全部订单</view>
					</view>
					<view class="" @click="$fun.jump('/pageA/order/order?state=1')">
						<image src="../../static/nav(2).png" mode=""></image>
						<view class="">待付款</view>
					</view>
					<view class="" @click="$fun.jump('/pageA/order/order?state=3')">
						<image src="../../static/nav(1).png" mode=""></image>
						<view class="">待收货</view>
					</view>
					<view class="" @click="$fun.jump('/pageA/order/order?state=4')">
						<image src="../../static/nav(4).png" mode=""></image>
						<view class="">已完成</view>
					</view>
				</view>
				<view class="usermain_wallet">
					<view class="usermain_wallet_top" @click="onDetali()">
						<view class="left">
							<view class="line"></view>
							<view class="">我的钱包</view>
						</view>
						<image src="../../static/next.png" mode=""></image>
					</view>
					<view class="usermain_wallet_list" v-for="(item,index) in balanceList" :key="index">
						<view class="naview" v-for="(fon,fonindex) in item" :key="fonindex" @click="onDetali()">
							<view class="">{{fon.money}}</view>
							<view class="name">{{fon.name}}</view>
						</view>
					</view>
				</view>
				<view class="share">
					<image src="../../static/shareimg.png" mode="" @click="jump(`/pageA/share`)"></image>
				</view>
				<view class="classList">
					<view class="classItem" @click="jump(item.url)" v-for="(item,index) in ywList" :key="index">
						<image :src="$fun.imgUrl(item.image)" mode=""></image>
						<view class="text">
							{{item.name}}
						</view>
					</view>
				</view>
			</view>
			<view style="height: 170upx;">

			</view>
		</view>
		<TabBar :tabBarShow="4"></TabBar>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				userInfo: {},
				balanceList: [],
				list: [],
				ywList: [],
				statusBarHeight: 0
			};
		},
		// 分享好友
		onShareAppMessage() {
			return {
				title: '鲲鱬云',
				path: JSON.parse(uni.getStorageSync('gitH5Qrcode')),
			}
		},
		// 分享朋友圈
		onShareTimeline() {
			return {
				title: '鲲鱬云',
				query: JSON.parse(uni.getStorageSync('gitH5Qrcode')),
			}
		},
		async onShow() {
			const phoneInfo = uni.getSystemInfoSync(); // 获取手机系统信息
			this.statusBarHeight = phoneInfo.statusBarHeight
			await this.$fun.ajax.post('user/index', {}).then(res => {
				if (res.code == 1) {
					this.userInfo = res.data
				}
			})
			await this.$fun.ajax.post('user/balance', {}).then(res => {
				if (res.code == 1) {
					this.balanceList = []
					const size = 3
					for (let i = 0; i < res.data.length; i += size) {
						this.balanceList.push(res.data.slice(i, i + size));
					}
				}
			})
			await this.$fun.ajax.post('index/category', {}).then(res => {
				if (res.code == 1) {
					this.ywList = res.data
				}
			})
		},
		methods: {
			jump(url) {
				if (url.indexOf('http') != -1) {
					this.$fun.jump(`/pageA/webView/webView?url=${url}&name=网络测速`, 0, 0)
				} else {
					this.$fun.jump(url, 0, 0)
				}
			},
			goup(levelname) {
				if (levelname == '粉丝') {
					this.$fun.jump(`/pages/equipment/equipment`, 0, 0)
				} else {
					this.$fun.jump(`/pageA/share`, 0, 0)
				}
			},
			uploadPic() {
				let _this = this
				uni.chooseImage({
					count: 1,
					success: res => {
						let tempFilePaths = res.tempFilePaths[0]
						uni.uploadFile({
							url: this.$baseUrl + '/api/common/upload', // 仅为示例，非真实的接口地址 
							filePath: tempFilePaths,
							name: 'file',
							header: {
								token: uni.getStorageSync('token')
							},
							success(res) {
								var res = JSON.parse(res.data)
								let userDate = {
									avatar: res.data.url,
								}
								_this.$fun.ajax.post('user/profile', {
									...userDate
								}).then(res1 => {
									if (res.code == 1) {
										_this.userInfo.avatar = res.data.fullurl

									}
								})
							},
						})
					}
				})
			},
			onDetali(item) {
				this.$fun.jump('/pageA/wallet/wallet')
			}
		}
	}
</script>

<style lang="scss">
	.usertop {
		width: 750rpx;
		height: 520rpx;
		background: linear-gradient(180deg, #5990FF 0%, #54d7ff 80%);

		.set {
			display: flex;
			justify-content: flex-end;
			padding-right: 30rpx;
			width: 750rpx;
			height: 88rpx;
			border-radius: 1rpx;
			align-items: center;

			image {
				width: 48rpx;
				height: 46rpx;
			}
		}


	}

	.isuser {
		position: absolute;
		top: 90rpx
	}

	.ediauser {
		display: flex;
		justify-content: space-between;
		margin: 0 30rpx;
		align-items: center;

		.ediauser_left image {
			width: 120rpx;
			height: 120rpx;
			border: 4rpx solid #FFFFFF;
			border-radius: 50%;
			margin-right: 20rpx;
		}

		&_left {
			font-weight: 500;
			font-size: 36rpx;
			color: #FFFFFF;
			display: flex;
			align-items: center;

			.textid {
				font-weight: 400;
				font-size: 28rpx;
				color: #FFFFFF;
			}
		}

		image {
			width: 48rpx;
			height: 48rpx;
		}
	}

	.usertop_bot {
		width: 690rpx;
		height: 88rpx;
		border-radius: 24rpx 24rpx 0rpx 0rpx;
		background-image: url('../../static/bg2@2x.png');
		background-size: 100% 100%;
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin: 40rpx auto 0;
		padding: 0 28rpx 0 22rpx;

		.left {
			font-weight: 500;
			font-size: 28rpx;
			color: #FFFFFF;
			display: flex;
			align-items: center;

			image {
				width: 48rpx;
				height: 48rpx;
				margin-right: 12rpx;
			}
		}

		.right {
			width: 120rpx;
			height: 48rpx;
			line-height: 48rpx;
			text-align: center;
			background: #FDF1C6;
			border-radius: 48rpx;
			font-weight: 500;
			font-size: 24rpx;
			color: #423831;
		}
	}

	.usermain {
		width: 750rpx;
		background: #F5F1EE;
		border-radius: 32rpx 32rpx 0rpx 0rpx;
		// margin-top: -184rpx;
		padding: 30rpx;

		&_nab {
			width: 690rpx;
			height: 154rpx;
			background: #FFFFFF;
			border-radius: 24rpx;
			margin: 0 auto;
			display: flex;
			justify-content: space-around;
			align-items: center;
			font-weight: 400;
			font-size: 20rpx;
			color: #333333;

			view {
				text-align: center;
			}

			image {
				width: 64rpx;
				height: 64rpx;
			}
		}

		.usermain_wallet {
			width: 690rpx;
			// height: 272rpx;
			background: #FFFFFF;
			border-radius: 24rpx;
			margin: 30rpx auto;
			padding-bottom: 30rpx;

			&_top {
				display: flex;
				justify-content: space-between;
				height: 88rpx;
				align-items: center;

				.left {
					font-weight: 600;
					font-size: 28rpx;
					color: #333333;
					display: flex;
					align-items: center;

					.line {
						width: 8rpx;
						height: 28rpx;
						background: #5990FF;
						margin-right: 22rpx;
					}
				}

				image {
					width: 48rpx;
					height: 48rpx;
				}
			}

			&_list {
				font-weight: 500;
				font-size: 24rpx;
				color: #333333;
				display: flex;

				padding-left: 30rpx;
				padding-right: 30rpx;

				.naview {
					width: 33%;
				}

				.name {
					font-weight: 400;
					font-size: 24rpx;
					color: #999999;
				}
			}

			&_list:nth-child(3),
			&_list:nth-child(4) {
				margin-top: 30rpx;
			}
		}

		.share {
			margin: 0 auto;
			margin-bottom: 30rpx;

			image {
				width: 690rpx;
				height: 180rpx;
				border-radius: 24rpx;
			}
		}

		.classList {
			display: flex;
			flex-wrap: wrap;
			width: 690rpx;
			// height: 294rpx;
			background: #FFFFFF;
			border-radius: 24rpx;
			margin: 30rpx auto;
			padding: 30rpx 0rpx 10rpx;

			.classItem {
				width: 20%;
				display: flex;
				margin-bottom: 20rpx;
				flex-direction: column;
				align-items: center;

				image {
					width: 72rpx;
					height: 72rpx;
				}

				.text {
					margin-top: 10rpx;
					font-weight: 500;
					font-size: 20rpx;
					color: #333333;
				}
			}
		}
	}
</style>